package vip.xiaonuo.smzq.modular.nbfb.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.smzq.modular.nbfb.entity.param.KszyclParam;
import vip.xiaonuo.smzq.modular.nbfb.entity.vo.KczyVo;
import vip.xiaonuo.smzq.modular.nbfb.service.IKszyclService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 矿产资源储量表
 *
 * @author sqq
 * @since 2024-08-28
 */
@Api(tags = "矿产资源储量")
@RestController
@RequestMapping("/nbfb/kczy")
@Validated
public class KczyController {

    @Resource
    private IKszyclService kczyService;


    /**
     * 查询矿山资源储量表
     *
     * @param param
     * @author sqq
     * @since 2024/8/20
     */
    @ApiOperation(value = "查询矿山资源储量表")
    @PostMapping(value = "getKczyVoList")
    public CommonResult<List<KczyVo>> getKczyVoList(@RequestBody KszyclParam param) {

        return CommonResult.data(kczyService.getKczyVoList(param));
    }

    /**
     * 导出矿产资源储量表
     *
     * @param param
     * @param response
     * @author sqq
     * @since 2024/8/29 9:54
     */
    @ApiOperation(value = "导出矿产资源储量表")
    @PostMapping(value = "exportKszycl")
    public void exportKszycl(@RequestBody KszyclParam param,
                             HttpServletResponse response) {
        // 设置响应头
        response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
        response.setHeader("ContentType", "application/msword");
        // 设置字符编码
        response.setCharacterEncoding("UTF-8");
        kczyService.exportKszycl(param, response);
    }

    /**
     * 导出矿产资源储量表目录
     *
     * @param param
     * @param response
     * @author sqq
     * @since 2024/8/29 9:54
     */
    @ApiOperation(value = "导出矿产资源储量表目录")
    @PostMapping(value = "exportKszclMl")
    public void exportKszyclMl(@RequestBody KszyclParam param,
                               HttpServletResponse response) {
        // 设置响应头
        response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
        response.setHeader("ContentType", "application/msword");
        // 设置字符编码
        response.setCharacterEncoding("UTF-8");
        kczyService.exportKszclMl(param, response);
    }

    @ApiOperation(value = "导出矿产资源储量表测试")
    @GetMapping(value = "exportKszycl2")
    public void exportKszycl(HttpServletResponse response) {
        KszyclParam param = new KszyclParam();
        param.setNd(2023);
        param.setKcdl(700400);
        // 设置响应头
        response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
        response.setHeader("ContentType", "application/msword");
        // 设置字符编码
        response.setCharacterEncoding("UTF-8");
        kczyService.exportKszycl(param, response);
    }

    @ApiOperation(value = "导出矿产资源储量表目录测试")
    @GetMapping(value = "exportKszyclMl2")
    public void exportKszyclMl(HttpServletResponse response) {
        KszyclParam param = new KszyclParam();
        param.setNd(2024);
        param.setKcdl(700300);
        param.setXzqh("130401,130402,130403,130404,130406,130407,130408,130423,130424,130425,130426,130427,130430,130431,130432,130433,130434,130435,130471,130473,130481,130501,130502,130503,130505,130506,130522,130523,130524,130525,130528,130529,130530,130531,130532,130533,130534,130535,130571,130581,130582,130601,130602,130606,130607,130608,130609,130623,130624,130626,130627,130628,130629,130630,130631,130632,130633,130634,130635,130636,130637,130638,130671,130672,130681,130682,130683,130684,130701,130702,130703,130705,130706,130708,130709,130722,130723,130724,130725,130726,130727,130728,130730,130731,130732,130771,130772,130773,130801,130802,130803,130804,130821,130822,130824,130825,130826,130827,130828,130871,130881,130901,130902,130903,130921,130922,130923,130924,130925,130926,130927,130928,130929,130930,130971,130972,130973,130981,130982,130983,130984,131001,131002,131003,131022,131023,131024,131025,131026,131028,131071,131081,131082,131101,131102,131103,131121,131122,131123,131124,131125,131126,131127,131128,131171,131172,131182,130101,130102,130104,130105,130107,130108,130109,130110,130111,130121,130123,130125,130126,130127,130128,130129,130130,130131,130132,130133,130171,130172,130181,130183,130184,130201,130202,130203,130204,130205,130207,130208,130209,130224,130225,130227,130229,130271,130272,130273,130274,130281,130283,130284,130371,130372,130301,130302,130303,130304,130306,130321,130322,130324");
        param.setFileId("ce49a7d1-a148-4aa2-a48e-3d319ad49917");
        // 设置响应头
        response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
        response.setHeader("ContentType", "application/msword");
        // 设置字符编码
        response.setCharacterEncoding("UTF-8");
        kczyService.exportKszclMl(param, response);
    }
}
